package com.yazi.mxz.common.db.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.yazi.mxz.common.db.dao.StoreDao;
import com.yazi.mxz.common.entity.beans.Region;
import com.yazi.mxz.common.entity.beans.Store;

import com.myframework.smhj.hibernate.dao.BasicDao;

@Repository("storeDao")
public class StoreDaoImpl extends BasicDao<Store> implements StoreDao {


	public StoreDaoImpl() {
		super(Store.class);
	}

	@Override
	public Criteria getExample(Store store, String searchWord) {
		Criteria c = super.getExample(store, searchWord);
		if (null != store) {
			// 地区
			Region region = store.getRegion();
			if (null != region) {
				// 地区ID
				if(null != region.getRegionId()){
					c.add(Restrictions.eq("region.regionId", region.getRegionId()));
				} else {
					// ...地区其它条件
				}
			}
			// ...店铺其它关联对象条件
		}
		// ...关键字searchWord查询条件
		return c;
	}

}
